$(function(){
	$('.btn-selectall').click(function(){
		$('#link-list').uiTable('selectAll');
	});
	$('.del-all-links').click(function(){
		var ids = $('#link-list').uiTable('selected');
		if(ids.length == 0){
			alert('请选择要删除的友情链接');
			return false;
		}
		if(!confirm('你确定要删除所选的友情链接?')){
			return false;
		}
		window.location.href = './?Ctlr=DelLink&lid='+ids.join(',');
		return false;
	});
	$('.set-all-display').click(function(){
		var ids = $('#link-list').uiTable('selected'),d = $(this).attr('rel');
		if(ids.length == 0){
			alert('请选择要设置可见性的友情链接');
			return false;
		}		
		if(!confirm('你确定要将所选的友情链接设为'+(d==0?'不':'')+'可见?')){
			return false;
		}
		window.location.href = './?Ctlr=ShowLink&lid='+ids.join(',')+'&d='+d;
		return false;
	});
	$('.link-sort').change(function() {
        var me = $(this), sort = me.val(), lid = me.attr('rel');
        if(/^[0-9]{1,4}$/.test(sort)) {
            me.addClass('ico-loading-14r').attr('disabled', 'disabled');
            $.ajax({
                url : './?Ctlr=SetLinkSort&lid=' + lid + '&sort=' + sort,
                success : function(data) {
                    if(!data.success) {
                        alert(data.msg);
                    }
                    me.removeClass('ico-loading-14r').removeAttr('disabled');
                }
            });
        } else {
            me.focus();
            alert('只能是数值');
        }
    });
});